package edu.calvin.djs32.cs214.interpreters.calculator;

import edu.calvin.cs214.hobbes2008.HobbesTIR;
import edu.calvin.cs214.hobbes2008.IdentifierTIR;
import edu.calvin.cs214.hobbes2008.environments.IEnvironment;
import edu.calvin.cs214.hobbes2008.environments.NullEnvironment;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.AbsPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.AddPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.DividePrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.EqualsToPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.FactorialPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.GreaterThanOrEqualsToPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.GreaterThanPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.LessThanOrEqualsToPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.LessThanPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.MaxPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.MinPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.MultiplyPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.NotEqualsToPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.PowPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.SqrtPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.SquarePrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.SubtractPrimitive;
import edu.calvin.djs32.cs214.interpreters.calculator.primitives.TRefPrimitive;

public class CalculatorFactory {
	
	public CalculatorFactory(){
		
	}
	
	public Calculator createCalculator(){
		IEnvironment<Applicable> myPrimitives;
		IEnvironment<HobbesTIR> myEnvironment;
		myEnvironment = new NullEnvironment<HobbesTIR>();
		myPrimitives = new NullEnvironment<Applicable>().create();
		myPrimitives.add(new IdentifierTIR("+"), new AddPrimitive());
		myPrimitives.add(new IdentifierTIR("-"), new SubtractPrimitive());
		myPrimitives.add(new IdentifierTIR("/"), new DividePrimitive());
		myPrimitives.add(new IdentifierTIR("*"), new MultiplyPrimitive());
		myPrimitives.add(new IdentifierTIR("abs"), new AbsPrimitive());
		myPrimitives.add(new IdentifierTIR("max"), new MaxPrimitive());
		myPrimitives.add(new IdentifierTIR("min"), new MinPrimitive());
		myPrimitives.add(new IdentifierTIR("square"), new SquarePrimitive());
		myPrimitives.add(new IdentifierTIR("sqrt"), new SqrtPrimitive());
		myPrimitives.add(new IdentifierTIR("pow"), new PowPrimitive());
		myPrimitives.add(new IdentifierTIR("!"), new FactorialPrimitive());
		myPrimitives.add(new IdentifierTIR(">"), new GreaterThanPrimitive());
		myPrimitives.add(new IdentifierTIR(">="), new GreaterThanOrEqualsToPrimitive());
		myPrimitives.add(new IdentifierTIR("<"), new LessThanPrimitive());
		myPrimitives.add(new IdentifierTIR("<="), new LessThanOrEqualsToPrimitive());
		myPrimitives.add(new IdentifierTIR("="), new EqualsToPrimitive());
		myPrimitives.add(new IdentifierTIR("!="), new NotEqualsToPrimitive());
		myPrimitives.add(new IdentifierTIR("tref"), new TRefPrimitive());
		return new Calculator(myPrimitives, myEnvironment);
		
	}

}
